//1 trait bound 语法
//2 指定多个trait bound 
//3、返回 trait 类型
// pub trait GetInformation{
//     fn get_name(&self)->String;
//     fn get_age(&self)->u32;
// }
//第一种
// fn print_information1<T:GetInformation>(item:T){
//     println!("这里是trait作为参数：{} \n ",item.get_name())
// }
// //第二中 where
// fn print_information<T>(item:T) where T:GetInformation{
//     println!("这里是trait作为参数：{} \n ",item.get_name())
// }

//example

trait GetName{
    fn get_name(&self)->String;
}

trait GetAge{
    fn get_age(&self)->u32;
}
#[derive(Debug)]
pub struct Student{
    pub name:String,
    pub age:u32,
    pub sex:char
}
impl GetName for Student{
    fn get_name(&self)->String{
       format!("{}", self.name)
    }
}
impl GetAge for Student{
    fn get_age(&self)->u32{
        self.age
    }
}

impl Student{
    fn get_sex(&self){
       println!("性别：{}", self.sex)
    }
}
// impl SchoolName for Student{}

fn get_name_age<T:GetName+GetAge>(item:T){
    println!("name={}",item.get_name());
    println!("age={}",item.get_age());
}


fn produce_item_with_age()->impl GetAge{
    Student{
        name:String::from("Cha"),
        age:12,
        sex:'N'
    }
}




fn main(){
    let student=Student{
        name:String::from("Jhon"),
        age:23,
        sex:'女'
    };
    student.get_sex();
    get_name_age(student);
    let d =produce_item_with_age();
    println!("{:?}",d.get_age());
}